package com.fpt.mockproject.j21.absd.model;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "SUPPORTINGMATERIAL")
@DynamicUpdate(value = true)
public class SupportingMaterial {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "SupportingMaterialID", nullable = false, updatable = false, unique = true)
	private Long supportingMaterialID;
	
	@Column(name = "URL")
	private String url;
	
	@Column(name = "Description")
	private String description;
	
	@Column(name = "Types")
	private String type;
	
	@Column(name = "AddedDate", nullable = false)
	private Timestamp addDate;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "AddedBy")
	private User addByUser;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "OrgID")
	private Organisation organisation;
	
	public Organisation getOrganisation() {
		return organisation;
	}
	public void setOrganisation(Organisation organisation) {
		this.organisation = organisation;
	}
	public User getAddByUser() {
		return addByUser;
	}
	public void setAddByUser(User addByUser) {
		this.addByUser = addByUser;
	}
	public Long getSupportingMaterialID() {
		return supportingMaterialID;
	}
	public void setSupportingMaterialID(Long supportingMaterialID) {
		this.supportingMaterialID = supportingMaterialID;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Timestamp getAddDate() {
		return addDate;
	}
	
	// auto, just call it
	public void setAddDate() {
		java.util.Calendar cal = java.util.Calendar.getInstance();
		java.util.Date utilDate = cal.getTime();
		this.addDate = new Timestamp(utilDate.getTime());
	}
}
